home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++
- Subject: Re: NEWBIE : Quicksort
- Date: 25 Mar 1996 01:12:47 GMT
- Organization: Pipeline USA
- Message-ID: <4j4ruf$gf4@news1.h1.usa.pipeline.com>
- References: <Pine.SOL.3.91.960324135520.8433A-100000@orion>
- NNTP-Posting-Host: 38.8.120.9
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 24, 1996 14:00:23 in article <NEWBIE : Quicksort>, 'FRANCO
- <c2eyf931@sfsu.edu>' wrote:
-
-
- >Hello all.......
- >
- >I need some help. (for those who cares). I need to sort an array of
- >integers using the quicksort algorithm. (using partisioning and recursion)
-
- >Can anyone help?
- >
- #include <iostream.h>
- #include <stdlib.h>
-
-
- int comp(const void * a, const void * b)
- {
- return (*(int*)a - *(int*)b);
- }
-
-
- int main ()
- {
- int z[] = {5,3,7,12,100,32,80,21};
- int n = sizeof(z) / sizeof(int);
- qsort(z, n, sizeof(int), comp);
- for (int i = 0; i < n; i++)
- cout << ' ' << z[i];
- cout << endl;
- return 0;
- }
-
- --
-
- Pete Grant
- Kalevi, Inc.
- Sofware Engineering
-